const path = require("path");

//引入vue-loader的插件

const VueLoaderPlugin = require("vue-loader/lib/plugin");

module.exports = {
  //打包环境模式
  mode: "production",
  //入口文件
  entry: "./src/main.js",
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, "dist"),
  },
  //配置打包规则
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: "vue-loader",
      },
      {
        test: /\.(jpg|jpeg|png|svg)$/,
        loader: "url-loader",
        options: {
          name: `[name].[ext]`,
          limit: 2048,
        },
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"],
      },
      {
        test: /\.less$/,
        use: ["vue-style-loader", "css-loader","less-loader"],
      },
    ],
  },
  //插件配置
  plugins: [new VueLoaderPlugin()],
  resolve: {
    alias: {
      vue: "vue/dist/vue.js",
    },
  },
};
